package com.springcloudalibaba.buyerOrder.controller;

import com.springcloudalibaba.bclass.base.BaseResult;
import com.springcloudalibaba.buyerOrder.entity.BuyerOrderEntity;
import com.springcloudalibaba.buyerOrder.service.BuyerOrderService;
import io.seata.core.context.RootContext;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 订单信息 前端控制器
 * </p>
 *
 * @author lixing_java@163.com
 * @since 2021-11-27
 */
@RestController
@RequestMapping("/order")
public class BuyerOrderController {
    @Resource
    private BuyerOrderService buyerOrderService;

    /**
     * @描述 创建订单
     * @作者 lixing
     * @日期 2021/6/17 8:50
     * @Param [BuyerOrderEntity]
     * @return com.eureka.bclass.base.BaseResult<java.lang.String>
     */
    @PostMapping("createOrder")
    public BaseResult<String> createOrder(@RequestBody BuyerOrderEntity po) {
        System.out.println("xid========================" + RootContext.getXID());
        boolean flag = buyerOrderService.save(po);
        return flag ? new BaseResult<String>().success("添加成功") : new BaseResult<String>().fail("添加失败");
    }
}

